/*
* Copyright (c) 2013 City University of Hongkong.
*                    Cloud computing security group.
* 
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*
* mc_ssta.h - implment Monte Carlo SSTA.
*
* Authors: Xingliang Yuan     
* Emails:  xyuan86@gmail.com
*
*/


#ifndef MC_SSTA_H
#define MC_SSTA_H
#include "../graph/ff_graph.h"
#include "mc_utility.h"

class mc_ssta: public mc_utility
{
protected: 
    unsigned int clock_time;        // clock time

    unsigned long rand_seed;     //random seed to reproduce MC-SSTA
    
    vector<float> mc_vertex_delay; // deterministic vertex delay
    vector<float> vertex_arrive_time; // vertex arrive time
    
    /*  
    * description: generate deterministic delay for one MC simulation
    * param: ff_graph instance address
    * return: 
    */
    void gen_mc_delay(class ff_graph& ff_obj);

    /*  
    * description: PERT STA implementation following topological order
    * param: ff_graph instance address; 
    * return: maximum path delay
    */
    float sta_pert(class ff_graph& ff_obj);

public:
    /*  
    * description: MC-SSTA each simulation is PERT-STA
    * param: ff_graph instance; MC simulation number
    * return: circuit timing yield -- 
    *           the probablity that timing constraints are satified 
    */
    float mc_ssta_pert(class ff_graph& ff_obj, 
                    unsigned int mc_num, float clock);
};

#endif // MC_SSTA_H

